﻿
KE.lang['code'] = "插入程序代码或脚本";
KE.plugin['code'] = {
    click: function (id) {
        KE.util.selection(id);
        var dialog = new KE.dialog({
            id: id,
            cmd: 'code',
            file: '/insertCode/insert_code.html',
            width: 520,
            height: 280,
            title: KE.lang['code'],
            yesButton: KE.lang['yes'],
            noButton: KE.lang['no']
        });
        dialog.show();
    },
    check: function (id) {
        var dialogDoc = KE.util.getIframeDoc(KE.g[id].dialog);
        var lang = KE.$('ic_lang', dialogDoc).value;
        var source = KE.$('ic_source', dialogDoc).value;
        if (lang == '') {
            alert('编程语言必须选择');
            return false;
        }
        if (source == '') {
            alert('请输入程序代码或者脚本');
            return false;
        }
        return true;
    },
    exec: function (id) {
        KE.util.select(id);
        var iframeDoc = KE.g[id].iframeDoc;
        var dialogDoc = KE.util.getIframeDoc(KE.g[id].dialog);
        if (!this.check(id)) return false;
        var lang = KE.$('ic_lang', dialogDoc).value;
        var source = KE.$('ic_source', dialogDoc).value;
        this.insert(id, lang, source);
    },
    insert: function (id, lang, source) {
        var html = '<pre class="brush:' + lang + '">';
        html += source;
        html += '</pre>';
        KE.util.insertHtml(id, html);
        KE.layout.hide(id);
        KE.util.focus(id);
    }
};
function editerShow(txtID) {
    KE.show({
        id: txtID,
        resizeMode: 1,
        shadowMode: false,
        allowPreviewEmoticons: false,
        allowUpload: true,
        urlType: 'absolute',
        newlineTag: 'br',
        imageUploadJson: '/HTTP/upload_image.ashx',
        items: [
     'source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
		'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		'superscript', '|', 'selectall', '-',
		'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
		'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
		'flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink', '|', 'about', 'code']
    });
}